package com.iplant.mes.service.po.sfc;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.iplant.base.po.BasePO;
import com.iplant.base.po.enums.DBSchemas;
import com.iplant.base.utils.annotation.po.DBBasePO;
import com.iplant.base.utils.annotation.condition.DBCondition;
import com.iplant.base.utils.annotation.field.DBField;
import com.iplant.base.utils.annotation.join.DBJoin;
import com.iplant.mes.service.mesenum.sfc.SFCTaskStatus;
import com.iplant.mes.service.po.exc.EXCLineStop;
import com.iplant.mes.service.po.sfc.autoStation.SFCParameterItem;
import com.iplant.mes.service.po.sfc.autoStation.SFCStatusFeedbackItem;
import com.iplant.pdm.service.basicenum.pdm.PDMComponentTypes;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * 派工单
 *
 * @author YouWang·Peng
 * 2023-10-17 14:43:07
 */
@DBBasePO(TableName = "sfc_task_self", Name = false, Schemas = DBSchemas.MES,
        CheckName = {"Code", "TaskPartPointDayID,StationID,WorkerID"}, CodeAuto = true, CodePrefix = "APST-{yyMM}-")
public class SFCTaskSelf extends BasePO {
    @DBCondition
    @DBField
    public int OrderID = 0;

    @DBField
    public String OrderNo = "";

    @DBCondition
    @DBField
    public int RoutePartID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_routepart", tableAsName = "fpc_routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartName = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "fpc_routepart", tableAsName = "fpc_routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public String RoutePartCode = "";

    @DBJoin(name = "OrderID", tableName = "fpc_routepart", tableAsName = "fpc_routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public int RoutePartOrder = 0;

    @DBJoin(name = "RouteID", tableName = "fpc_routepart", tableAsName = "fpc_routepart1", Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartID")
    public int RouteID = 0;

    @DBCondition
    @DBField
    public int RoutePartPointID = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Name", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public String RoutePartPointName = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.like)
    @DBJoin(name = "Code", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public String RoutePartPointCode = "";

    @DBJoin(name = "OrderID", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public int RoutePartPointOrder = 0;

    @DBJoin(name = "ReportMode", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public int ReportMode = 0;

    @DBJoin(name = "ComponentType", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1", Schemas =
            DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public int ComponentType = 0;

    /**
     * 产出类型
     */
    public String ComponentTypeText = "";

    @DBJoin(name = "ScanComponentType", tableName = "fpc_routepartpoint", tableAsName = "fpc_routepartpoint1",
            Schemas = DBSchemas.PDM,
            MainTableField = "RoutePartPointID")
    public int ScanComponentType = 0;

    @DBCondition
    @DBField
    public int ProductID = 0;

    @DBJoin(name = "Code", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public String ProductCode = "";

    @DBJoin(name = "ComponentNumber", tableName = "fpc_product", tableAsName = "fpc_product1", Schemas = DBSchemas.PDM,
            MainTableField = "ProductID")
    public int ComponentNumber = 1;

    @DBField
    public int TaskPartID;

    @DBCondition
    @DBField
    public int TaskPartPointID;

    @DBCondition
    @DBField
    public int TaskPartPointDayID;

    @DBCondition
    @DBJoin(name = "IsRepairPlan", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1",
            Schemas =
                    DBSchemas.APS,
            MainTableField = "TaskPartPointDayID", JoinIndex = 4)
    public int IsRepairPlan = 0;

    @DBCondition
    @DBJoin(name = "ProductRepairID", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1",
            Schemas =
                    DBSchemas.APS,
            MainTableField = "TaskPartPointDayID", JoinIndex = 4)
    public int ProductRepairID = 0;

    /**
     * 首检状态
     */
    @DBCondition
    @DBJoin(name = "FirstCheckStatus", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1",
            Schemas =
                    DBSchemas.APS,
            MainTableField = "TaskPartPointDayID", JoinIndex = 4)
    public int FirstCheckStatus = 0;

    /**
     * 车间ID
     */
    @DBCondition
    @DBField
    public int WorkShopID = 0;
    @DBJoin(name = "Name", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopName = "";
    /**
     * 车间编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workshop", tableAsName = "workshop1", Schemas = DBSchemas.Basic,
            JoinIndex = 2,
            MainTableField = "WorkShopID")
    public String WorkShopCode = "";

    /**
     * 工区ID
     */
    @DBCondition
    @DBField
    public int WorkAreaID = 0;
    /**
     * 工区名称
     */
    @DBJoin(name = "Name", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaName = "";
    /**
     * 工区编码
     */
    @DBJoin(name = "Code", tableName = "fmc_workarea", tableAsName = "workarea1", Schemas = DBSchemas.Basic,
            JoinIndex = 3,
            MainTableField = "WorkAreaID")
    public String WorkAreaCode = "";

    /**
     * 工位ID
     */
    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int StationID = 0;
    /**
     * 工位名称
     */
    @DBJoin(name = "Name", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationName = "";
    /**
     * 工位编码
     */
    @DBJoin(name = "Code", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public String StationCode = "";
    /**
     * 条码类型
     */
    @DBJoin(name = "BarCodeType", tableName = "fmc_station", tableAsName = "station1", Schemas = DBSchemas.Basic,
            JoinIndex = 4,
            MainTableField = "StationID")
    public int BarCodeType = 0;

    @DBCondition(CompareType = DBCondition.DBCompareType.geLe, ParamName = "StaStartTime", ParamName2 = "StaEndTime")
    @DBField
    public Calendar StationDate = Calendar.getInstance();

    @DBCondition
    @DBField
    public int ShiftType = 0;
    /**
     * 原计划数量
     */
    @DBJoin(name = "PlantNum", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1", Schemas =
            DBSchemas.APS,
            JoinIndex = 4,
            MainTableField = "TaskPartPointDayID")
    public float SPlantNum = 0.0f;

    /**
     * 当班次班组长确定计划数
     */
    @DBJoin(name = "DPlantNum", tableName = "aps_task_partpoint_day", tableAsName = "aps_task_partpoint_day1", Schemas =
            DBSchemas.APS,
            JoinIndex = 4,
            MainTableField = "TaskPartPointDayID")
    public float DPlantNum = 0.0f;
    /**
     * 个人计划数
     * 给每个人的计划数量  几个人的加起来要默认等于PlantNum
     */
    @DBField
    public float PlantNum = 0.0f;

    /**
     * 产出计划数量
     */
    public float PlantComNum = 0.0f;

    /**
     * 产出实际数量
     */
    @DBField
    public float ActComNum = 0.0f;

    /**
     * 实际执行数量（成品）
     */
    @DBField
    public float ActNum = 0.0f;

    /**
     * 作业人ID
     */
    @DBCondition
    @DBField
    public int WorkerID = 0;
    /**
     * 作业人名称
     */
    @DBJoin(name = "Name", tableName = "mbs_user", tableAsName = "mbs_user1", Schemas = DBSchemas.Basic,
            MainTableField = "WorkerID")
    public String WorkerName = "";

    @DBCondition(CompareType = DBCondition.DBCompareType.in)
    @DBField
    public int Status = 0;

    public String StatusText = "";

    /**
     * 是否做了首检
     */
    @DBField
    @DBCondition
    public int IsFirstChecked = 0;

    //辅助属性，设备接口集成使用 2023-12-18 14:16:51
    /**
     * 物料清单
     */
    public List<SFCStatusFeedbackItem> MaterialList = new ArrayList<>();
    /**
     * 工艺参数
     */
    public List<SFCParameterItem> ParameterList = new ArrayList<>();
    /**
     * 质量参数
     */
    public List<SFCParameterItem> ParameterQList = new ArrayList<>();

    /**
     * 警告信息
     */
    public String StopReason = "";

    /**
     * 停线单
     */
    public EXCLineStop EXCLineStop = new EXCLineStop();

    @JsonProperty("OrderID")
    public int getOrderID() {
        return OrderID;
    }

    public void setOrderID(int orderID) {
        OrderID = orderID;
    }

    @JsonProperty("OrderNo")
    public String getOrderNo() {
        return OrderNo;
    }

    public void setOrderNo(String orderNo) {
        OrderNo = orderNo;
    }

    @JsonProperty("RoutePartID")
    public int getRoutePartID() {
        return RoutePartID;
    }

    public void setRoutePartID(int routePartID) {
        RoutePartID = routePartID;
    }

    @JsonProperty("RoutePartName")
    public String getRoutePartName() {
        return RoutePartName;
    }

    public void setRoutePartName(String routePartName) {
        RoutePartName = routePartName;
    }

    @JsonProperty("RoutePartPointID")
    public int getRoutePartPointID() {
        return RoutePartPointID;
    }

    public void setRoutePartPointID(int routePartPointID) {
        RoutePartPointID = routePartPointID;
    }

    @JsonProperty("RoutePartPointName")
    public String getRoutePartPointName() {
        return RoutePartPointName;
    }

    public void setRoutePartPointName(String routePartPointName) {
        RoutePartPointName = routePartPointName;
    }

    @JsonProperty("ComponentType")
    public int getComponentType() {
        return ComponentType;
    }

    public void setComponentType(int componentType) {
        ComponentType = componentType;
    }

    @JsonProperty("TaskPartID")
    public int getTaskPartID() {
        return TaskPartID;
    }

    public void setTaskPartID(int taskPartID) {
        TaskPartID = taskPartID;
    }

    @JsonProperty("TaskPartPointID")
    public int getTaskPartPointID() {
        return TaskPartPointID;
    }

    public void setTaskPartPointID(int taskPartPointID) {
        TaskPartPointID = taskPartPointID;
    }

    @JsonProperty("TaskStationID")
    public int getTaskPartPointDayID() {
        return TaskPartPointDayID;
    }

    public void setTaskPartPointDayID(int taskPartPointDayID) {
        TaskPartPointDayID = taskPartPointDayID;
    }

    @JsonProperty("WorkShopID")
    public int getWorkShopID() {
        return WorkShopID;
    }

    public void setWorkShopID(int workShopID) {
        WorkShopID = workShopID;
    }

    @JsonProperty("WorkShopName")
    public String getWorkShopName() {
        return WorkShopName;
    }

    public void setWorkShopName(String workShopName) {
        WorkShopName = workShopName;
    }

    @JsonProperty("WorkShopCode")
    public String getWorkShopCode() {
        return WorkShopCode;
    }

    public void setWorkShopCode(String workShopCode) {
        WorkShopCode = workShopCode;
    }

    @JsonProperty("WorkAreaID")
    public int getWorkAreaID() {
        return WorkAreaID;
    }

    public void setWorkAreaID(int workAreaID) {
        WorkAreaID = workAreaID;
    }

    @JsonProperty("WorkAreaName")
    public String getWorkAreaName() {
        return WorkAreaName;
    }

    public void setWorkAreaName(String workAreaName) {
        WorkAreaName = workAreaName;
    }

    @JsonProperty("WorkAreaCode")
    public String getWorkAreaCode() {
        return WorkAreaCode;
    }

    public void setWorkAreaCode(String workAreaCode) {
        WorkAreaCode = workAreaCode;
    }

    @JsonProperty("StationID")
    public int getStationID() {
        return StationID;
    }

    public void setStationID(int stationID) {
        StationID = stationID;
    }

    @JsonProperty("StationName")
    public String getStationName() {
        return StationName;
    }

    public void setStationName(String stationName) {
        StationName = stationName;
    }

    @JsonProperty("StationCode")
    public String getStationCode() {
        return StationCode;
    }

    public void setStationCode(String stationCode) {
        StationCode = stationCode;
    }

    @JsonProperty("StationDate")
    public Calendar getStationDate() {
        return StationDate;
    }

    public void setStationDate(Calendar stationDate) {
        StationDate = stationDate;
    }

    @JsonProperty("ShiftType")
    public int getShiftType() {
        return ShiftType;
    }

    public void setShiftType(int shiftType) {
        ShiftType = shiftType;
    }

    @JsonProperty("ProductID")
    public int getProductID() {
        return ProductID;
    }

    public void setProductID(int productID) {
        ProductID = productID;
    }

    @JsonProperty("ProductCode")
    public String getProductCode() {
        return ProductCode;
    }

    public void setProductCode(String productCode) {
        ProductCode = productCode;
    }

    @JsonProperty("ComponentNumber")
    public int getComponentNumber() {
        return ComponentNumber;
    }

    public void setComponentNumber(int componentNumber) {
        ComponentNumber = componentNumber;
    }

    @JsonProperty("SPlantNum")
    public float getSPlantNum() {
        return SPlantNum;
    }

    public void setSPlantNum(float SPlantNum) {
        this.SPlantNum = SPlantNum;
    }

    @JsonProperty("DPlantNum")
    public float getDPlantNum() {
        return DPlantNum;
    }

    public void setDPlantNum(float DPlantNum) {
        this.DPlantNum = DPlantNum;
    }

    @JsonProperty("PlantNum")
    public float getPlantNum() {
        return PlantNum;
    }

    public void setPlantNum(float plantNum) {
        PlantNum = plantNum;
    }

    @JsonProperty("PlantComNum")
    public float getPlantComNum() {
        return PlantComNum;
    }

    public void setPlantComNum(float plantComNum) {
        PlantComNum = plantComNum;
    }

    @JsonProperty("ActNum")
    public float getActNum() {
        return ActNum;
    }

    public void setActNum(float actNum) {
        ActNum = actNum;
    }

    @JsonProperty("ActComNum")
    public float getActComNum() {
        return ActComNum;
    }

    public void setActComNum(float actComNum) {
        ActComNum = actComNum;
    }

    @JsonProperty("WorkerID")
    public int getWorkerID() {
        return WorkerID;
    }

    public void setWorkerID(int workerID) {
        WorkerID = workerID;
    }

    @JsonProperty("WorkerName")
    public String getWorkerName() {
        return WorkerName;
    }

    public void setWorkerName(String workerName) {
        WorkerName = workerName;
    }

    @JsonProperty("Status")
    public int getStatus() {
        return Status;
    }

    public void setStatus(int status) {
        Status = status;
    }

    @JsonProperty("StatusText")
    public String getStatusText() {
        StatusText = SFCTaskStatus.getEnumType(Status).getLabel();
        return StatusText;
    }

    public void setStatusText(String statusText) {
        StatusText = statusText;
    }

    @JsonProperty("IsFirstChecked")
    public int getIsFirstChecked() {
        return IsFirstChecked;
    }

    public void setIsFirstChecked(int isFirstChecked) {
        IsFirstChecked = isFirstChecked;
    }

    @JsonProperty("ScanComponentType")
    public int getScanComponentType() {
        return ScanComponentType;
    }

    public void setScanComponentType(int scanComponentType) {
        ScanComponentType = scanComponentType;
    }

    @JsonProperty("ReportMode")
    public int getReportMode() {
        return ReportMode;
    }

    public void setReportMode(int reportMode) {
        ReportMode = reportMode;
    }

    @JsonProperty("MaterialList")
    public List<SFCStatusFeedbackItem> getMaterialList() {
        return MaterialList;
    }


    public void setMaterialList(List<SFCStatusFeedbackItem> materialList) {
        MaterialList = materialList;
    }

    @JsonProperty("ParameterList")
    public List<SFCParameterItem> getParameterList() {
        return ParameterList;
    }

    public void setParameterList(List<SFCParameterItem> parameterList) {
        ParameterList = parameterList;
    }

    @JsonProperty("ParameterQList")
    public List<SFCParameterItem> getParameterQList() {
        return ParameterQList;
    }

    public void setParameterQList(List<SFCParameterItem> parameterQList) {
        ParameterQList = parameterQList;
    }

    @JsonProperty("IsRepairPlan")
    public int getIsRepairPlan() {
        return IsRepairPlan;
    }

    public void setIsRepairPlan(int isRepairPlan) {
        IsRepairPlan = isRepairPlan;
    }

    @JsonProperty("RoutePartPointCode")
    public String getRoutePartPointCode() {
        return RoutePartPointCode;
    }

    public void setRoutePartPointCode(String routePartPointCode) {
        RoutePartPointCode = routePartPointCode;
    }

    @JsonProperty("RoutePartCode")
    public String getRoutePartCode() {
        return RoutePartCode;
    }

    public void setRoutePartCode(String routePartCode) {
        RoutePartCode = routePartCode;
    }

    @JsonProperty("RouteID")
    public int getRouteID() {
        return RouteID;
    }

    public void setRouteID(int routeID) {
        RouteID = routeID;
    }

    @JsonProperty("StopReason")
    public String getStopReason() {
        return StopReason;
    }

    public void setStopReason(String stopReason) {
        StopReason = stopReason;
    }

    @JsonProperty("EXCLineStop")
    public com.iplant.mes.service.po.exc.EXCLineStop getEXCLineStop() {
        return EXCLineStop;
    }

    public void setEXCLineStop(com.iplant.mes.service.po.exc.EXCLineStop EXCLineStop) {
        this.EXCLineStop = EXCLineStop;
    }

    @JsonProperty("RoutePartOrder")
    public int getRoutePartOrder() {
        return RoutePartOrder;
    }

    public void setRoutePartOrder(int routePartOrder) {
        RoutePartOrder = routePartOrder;
    }

    @JsonProperty("RoutePartPointOrder")
    public int getRoutePartPointOrder() {
        return RoutePartPointOrder;
    }

    public void setRoutePartPointOrder(int routePartPointOrder) {
        RoutePartPointOrder = routePartPointOrder;
    }

    @JsonProperty("ProductRepairID")
    public int getProductRepairID() {
        return ProductRepairID;
    }

    public void setProductRepairID(int productRepairID) {
        ProductRepairID = productRepairID;
    }

    @JsonProperty("FirstCheckStatus")
    public int getFirstCheckStatus() {
        return FirstCheckStatus;
    }

    public void setFirstCheckStatus(int firstCheckStatus) {
        FirstCheckStatus = firstCheckStatus;
    }

    @JsonProperty("BarCodeType")
    public int getBarCodeType() {
        return BarCodeType;
    }

    public void setBarCodeType(int barCodeType) {
        BarCodeType = barCodeType;
    }

    @JsonProperty("ComponentTypeText")
    public String getComponentTypeText() {
        return PDMComponentTypes.getEnumType(ComponentType).getLabel();
    }

    public void setComponentTypeText(String componentTypeText) {
        ComponentTypeText = componentTypeText;
    }
}
